﻿@{
    ViewBag.Title = "RolePowerEdit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@{
    var action = ViewData["action"].ToString();
    string Id = ViewData["Id"].ToString();

    string width = ViewData["width"].ToString();
    if (action == "edit")
    {
        Id = ViewData["Id"].ToString();
    }

} 

<div class="mod_dialog" style="display:block;margin-top:@width;left:0px">

    <div class="hd">
            <h3>修改角色权限</h3>
    </div>
    <div class="bd">
        <div class="form clearfix nouse" data-col="0">

            <form id="frmAccount" class="layui-form" lay-filter="frmAccount">
                <ul class="clearfix">
                    <li>
                        <label class="label">角色名称：</label>
                        <div class="inptxt">
                            <p></p>
                            <input type="text" class="disabled" name="ROLE_NAME" lay-filter="ROLE_NAME" required lay-verify="required" autocomplete="off" class="layui-input" disabled="disabled">
                        </div>

                    </li>
                    @*<li>
                        <div class="layui-form-item">
                            <label class="label">客户管理：</label>
                            <div class="layui-input-block">
                                <input type="checkbox" name="IS_Company" lay-skin="switch" lay-filter="IS_Company" lay-text="开启|关闭" value="true">
                            </div>
                        </div>
                    </li>*@
                    <li>
                        <div class="layui-form-item">
                            <label class="label">监控管理：</label>
                            <div class="layui-input-block">
                                <input type="checkbox" name="IS_Monitor" lay-skin="switch" lay-filter="IS_Monitor" lay-text="开启|关闭" value="true">
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="layui-form-item">
                            <label class="label">报表管理：</label>
                            <div class="layui-input-block">
                                <input type="checkbox" name="IS_Report" lay-skin="switch" lay-filter="IS_Report" lay-text="开启|关闭" value="true">
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="layui-form-item">
                            <label class="label">资源管理：</label>
                            <div class="layui-input-block">
                                <input type="checkbox" name="IS_Resource" lay-skin="switch" lay-filter="IS_Resource" lay-text="开启|关闭" value="true">
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="layui-form-item">
                            <label class="label">消息管理：</label>
                            <div class="layui-input-block">
                                <input type="checkbox" name="IS_Message" lay-skin="switch" lay-filter="IS_Message" lay-text="开启|关闭" value="true">
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="layui-form-item">
                            <label class="label">系统设置：</label>
                            <div class="layui-input-block">
                                <input type="checkbox" name="IS_Setting" lay-skin="switch" lay-filter="IS_Setting" lay-text="开启|关闭" value="true">
                            </div>
                        </div>
                    </li>

                </ul>
            </form>
        </div>

    </div>
    <div class="fd">
        <div class="load_btn">
            @{if (action == "add")
            {
            <button class="btn_green_m" id="btnAdd">保存</button>
            <button class="btn_gray_m" id="btnCancel">取消</button>
            }
            else
            {
            <button class="btn_green_m" id="btnEdit">保存</button>
            <button class="btn_gray_m" id="btnCancel">取消</button>
            }}
        </div>
    </div>
</div>
<script type="text/javascript">

    $(function () {
        if ("@action" == "edit") {
            $.ajax({
                url: "/Setting/GetPowerById/@Id",
                type: "post",
                dataType: "json",
                success: function (data) {
                    var form = layui.form;
                    form.val("frmAccount", data);
                    form.render(); //刷新select选择框渲染
                }
            });
        }
        var form = layui.form;
        form.render(); //刷新select选择框渲染
    })


    $("#btnCancel").click(function () {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
        return false;
    });


    $("#btnEdit").click(function () {
        var account = com.serializeObj("frmAccount");
        //alert(JSON.stringify(account));
        account.ROLE_ID = "@Id";
        com.ajax({
            url: "/Setting/EditPower", data: account, success: function (data) {
                layer.confirm('权限修改成功，重新登录系统后生效！！！', {
                    btn: ['确定']
                }, function () {
                    parent.$("#infoList").datagrid("load");
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                })
            }
        });
    });
</script>